package com.ruoyi.common.swagger.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;

import java.util.stream.Collectors;
import java.util.stream.Stream;

@Configuration
public class SwaggerConfig {
    @Bean
    public Docket createRestApi() {
        return new Docket(DocumentationType.OAS_30)
                .useDefaultResponseMessages(false)
                .produces(Stream.of("application/xml", "application/json").collect(Collectors.toSet()))
                .select()// v2 不同
                //.apis(RequestHandlerSelectors.basePackage("com.xinjiang.electricpower.controller")) // 设置扫描路径
                //.paths(PathSelectors.regex("/xinjiang-power-supply-station/.*"))
                //.paths(PathSelectors.ant("/xinjiang-power-supply-station/**").or(PathSelectors.ant("/dict/**")))
                .paths(PathSelectors.regex("/xinjiang-power-supply-station/.*")
                        .or(PathSelectors.regex("/dict/.*"))
                      )
                .build()
                .protocols(Stream.of("http", "https").collect(Collectors.toSet()));
    }
}
